#include <bits/stdc++.h>
#include <string>
using namespace std;

const int size = 150;
int main()
{

	string str;
	getline(cin, str);
	int arr[size] = {0};
	for (int i = 0; i < str.length(); i++)
	{
		arr[(int)str.at(i)]++;
	}
	int index = 0,maxx = 0, times = 0;
	for (int i = 0; i < size; i++)
	{
		if (arr[i] > maxx)
		{
			index = i;
			maxx = arr[i];
			times = 1;
		}
		else if (arr[i] == maxx)
		{
			times++;
		}
	}
	if(times!=1) cout << -1;
	else cout << (char)index << " " << maxx;

	return 0;
}